
def check(ids):
    if len(ids) != 18:
        return False
    weights = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    chars = [chr(ord('0')+i) for i in range(10)]
    sum = 0
    for i in range(17):
        if ids[i] not in chars:
            return False
        else:
            sum = sum + int(ids[i])*weights[i]
    z = sum % 11
    M = [1,0,'X',9,8,7,6,5,4,3,2]
    M = list(map(str,M))
    if ids[17] == M[z]:
        return True
    else:
        return False
if __name__ == "__main__":
    print(check("320124198808240056"))
